<!DOCTYPE html>
<html>

<head>
    <#include "/dk/admin/components/meta.html" />
    <title>蓝天运动 ${metaTitleSuffix!}</title>
    <#include "/dk/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="1-1" />
            <#include "/dk/admin/components/menu.html" />
            <el-container>
                <#include "/dk/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-button @click='onAdd'>新增</el-button>
                        <el-date-picker v-model="date" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" @change="onDateChange" unlink-panels="true">
                        </el-date-picker>
                        <el-table :data="items" style="width: 100%">
                            <el-table-column prop="startTime" label="上课时间" width=200>
                            </el-table-column>
                            <el-table-column prop="courseTime" label="时长">
                                <template slot-scope="scope">
                                    <span>{{scope.row.courseTime}}分钟</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="courseName" label="课程名称">
                            </el-table-column>
                            <el-table-column prop="topic" label="主题">
                            </el-table-column>
                            <el-table-column prop="teacherName" label="老师">
                            </el-table-column>
                            <el-table-column prop="classroom" label="教室">
                            </el-table-column>
                            <el-table-column prop="limit" label="限定人数">
                                <template slot-scope="scope">
                                    <span v-if=scope.row.limit==0>不限定</span>
                                    <span v-else>{{scope.row.limit}}</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="joinCount" label="已订人数">
                            </el-table-column>
                            <el-table-column label="操作" width=300>
                                <template slot-scope="scope">
                                    <el-button size='small' @click=onEdit(scope.row)>编辑</el-button>
                                    <el-button size='small' @click=users(scope.row)>已定人数</el-button>
                                    <el-button size='small' @click=onDelete(scope.row) type='danger'>删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include '/components/page.html' />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/xhc/admin/components/footer.html" />
    </div>
<script src="http://res.zhen-yee.com/assert/vue.2.5.16.min.js"></script>
<script src="http://res.zhen-yee.com/assert/element-ui-2.4.7.js"></script>
<script src="http://res.zhen-yee.com/assert/qs.6.5.2.min.js"></script>
<script src="http://res.zhen-yee.com/assert/axios.0.18.0.min.js"></script>
    <script src="http://res.zhen-yee.com/assert/jquery-3.1.1.min.js"></script>
    <script src="http://res.zhen-yee.com/assert/layer-2.3.js"></script>
<link href="http://res.zhen-yee.com/assert/layer-2.3.css" rel="stylesheet">
    <script src="/components/utils.js"></script>
    <script src="/components/pageJs.js"></script>
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                date: ['${startTime!}', '${endTime!}'],
                items: JSON.parse(`${items![]}`)
            }
        },
        mounted: function() {},
        methods: {
            onAdd() {
                window.location.href = '/dk/admin/info'
            },
            onDelete(info) {
                this.$confirm('确定删除?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {
                        arrangeId: info.id
                    }
                    axiosRequest(param, '/dk/admin/delete', '')
                }).catch(() => {});
            },
            users(info) {
                window.location.href = '/dk/admin/users?arrangeId=' + info.id
            },
            onEdit(info) {
                window.location.href = '/dk/admin/info?arrangeId=' + info.id
                // var param = {
                //     arrangeId: info.id
                // }
                // axiosRequest(param, '/dk/admin/info', '')
            },
            onDateChange(val) {
                var keys = [
                    { key: 'startDate', value: val[0] },
                    { key: 'endDate', value: val[1] }
                ]
                goPage(1, keys)
            },
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
    <script>
    // vue.tableData = ${items!};
    </script>
</body>

</html>